package com.caoji.serach.web;

import com.caoji.serach.entity.Goods;
import com.caoji.serach.entity.SearchParamDTO;
import com.caoji.serach.service.EsService;

import com.leyou.starter.elastic.entity.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("goods")
public class esController {

    @Autowired
    EsService esService;


    /**
     * 初始化索引库
     */
    @GetMapping("/suggestion")
    public Mono<List<String>> getsuggest(@RequestParam("key")String key) {
        return esService.getsuggest(key);
    }

    @PostMapping("/list")
    public Mono<PageInfo<Goods>> getkist(@RequestBody SearchParamDTO searchParamDTO) {
        return esService.getkist(searchParamDTO);
    }
    @PostMapping("filter")
    public Mono<Map<String,List<?>>>  getfilter(@RequestBody SearchParamDTO searchParamDTO) {
        return esService.getfilter(searchParamDTO);
    }

}